package com.sztx.pay.center.rpc.component;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.sztx.pay.center.common.util.ValidateUtil;
import com.sztx.pay.center.common.util.Constance.PayFlowType;
import com.sztx.pay.center.core.service.OrderMappingService;
import com.sztx.pay.center.core.service.PayCoreService;
import com.sztx.pay.center.core.service.bean.PayCoreResult;
import com.sztx.pay.center.dataaccess.domain.UserActDO;
import com.sztx.pay.center.dataaccess.domain.UserBindCardDO;
import com.sztx.pay.center.rpc.api.domain.TradeBaseRequest;
import com.sztx.pay.center.rpc.api.domain.TradeResponse;
import com.sztx.se.common.exception.BusinessException;

public class ResendQuickVCService extends TradeService {

	@Autowired
	PayCoreService payCoreService;
	
	@Autowired
	OrderMappingService orderMappingService;
	
	
	@Override
	void checkPrivateParam(Map<String, String> params) {
		
		String tradeOrderId = params.get("tradeOrderId");
		
		ValidateUtil.isNotBlank(tradeOrderId, "tradeOrderId不能为空");
		
	}

	@Override
	boolean isRepeatOrder(Map<String, String> params) {
		return false;
	}

	@Override
	String recordOrder(TradeBaseRequest request) {
		return null;
	}

	@Override
	UserBindCardDO getPayerBindInfo(Map<String, String> params) {
		return null;
	}

	@Override
	UserBindCardDO getPayeeBindInfo(Map<String, String> params) {
		return null;
	}

	@Override
	UserActDO getPayerActInfo(TradeBaseRequest request) {
		return null;
	}

	@Override
	UserActDO getPayeeActInfo(TradeBaseRequest request) {
		return null;
	}

	@Override
	TradeResponse invokePayCore(Map<String, String> params) {
		
		String tradeOrderId = params.get("tradeOrderId");
		
		String referOrderId = orderMappingService.getMappingOrderId(tradeOrderId, (byte) PayFlowType.PAY.getCode());
		TradeResponse response = new TradeResponse();
		response.setTradeOrderId(tradeOrderId);
		try {
			payCoreService.resendQuickVC(referOrderId);
			response.setResultCode("3");
			response.setResultMsg("发送成功");
		} catch (BusinessException e) {
			response.setResultCode("4");
			response.setResultMsg(e.getMessage());
		}
		return response;
	}

	@Override
	void handerPayCoreResult() {
		
	}

}
